<template>
  <div>
    <el-row>
      <el-col :span="24">
        <p class="pinformation" style="margin-top: 7px">搜索条件</p>
      </el-col>
    </el-row>
    <el-form label-width="100px" :model="queryParams" ref="queryRef" :inline="true">
      <el-form-item label="检测类别：" prop="jclbId">
        <el-select v-model="queryParams.jclbId" clearable>
          <el-option
            v-for="item in proxy.addListNoLimit(jclbList, 'jclbId', 'jclbName')"
            :key="item.jclbId"
            :value="item.jclbId"
            :label="item.jclbName"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="检测项目：" prop="jcxmName">
        <el-input
          v-model="queryParams.jcxmName"
          clearable
          maxlength="100"
          @keyup.enter="handleQuery"
        ></el-input>
      </el-form-item>
      <el-form-item >
      <el-button type="success" @click="handleQuery">搜索</el-button>
      <el-button class="business resetBtn" @click="resetQuery">重置</el-button>
    </el-form-item>
    </el-form>
    <el-row>
      <p class="pinformation">检测项目拆分列表</p>
      <p class="totalStyle">共 {{ mergeJcxmList.length }} 条数据</p>
    </el-row>
    <el-table ref="mainTableRef" :data="mergeJcxmList" v-loading="loading">
      <el-table-column prop="jclbName" label="检测类别" align="center" />
      <el-table-column
        prop="jcxmNames"
        label="检测项目"
        align="center"
        width="250"
        show-overflow-tooltip
      >
        <template #default="scope">
          <span v-html="transformation(scope.row.jcxmNames)"></span>
        </template>
      </el-table-column>
      <el-table-column label="容器" align="center" prop="containerTypeName" />

      <el-table-column label="固定剂" align="center" width="250" show-overflow-tooltip>
        <template #default="scope">
          <span v-if="scope.row.fixerName"
            >{{ scope.row.fixerName }}
            ,
            {{ scope.row.fixerDescName }}</span
          >
        </template>
      </el-table-column>
      <el-table-column
        prop="saveDesc"
        label="保存要求"
        align="center"
        width="250"
        show-overflow-tooltip
      />
      <el-table-column label="操作" align="center" width="200" fixed="right">
        <template #default="scope">
        </template>
        </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { queryProjectJcxmList } from "@/api/project/sampleMerge";
import { projectListJclb } from "@/api/store/jclb";
const { proxy } = getCurrentInstance();
const loading = ref(false);
const projectId = ref("1782398771516387330");
const {
  sys_degree,
  sys_fixer,
  sys_fixer_desc,
  sys_sample_container,
} = proxy.useShareDict(
  "sys_fixer",
  "sys_fixer_desc",
  "sys_degree",
  "sys_sample_container"
);
const queryParams = ref({
  pageSize: 10,
  pageNum: 1,
  jclbId: -1,
  isCollect: -1,
});
const dateRange = ref([]);
const mergeJcxmList = ref([]);
const jclbList = ref([]);
const isCollectList = ref([
  { value: -1, label: "不限" },
  { value: 1, label: "是" },
  { value: 2, label: "否" },
]);
const props = defineProps({
  projectId: {
    type: String, //参数类型
  },
});

function getId() {
  nextTick(() => {
    // queryParams.value.projectId = props.projectId;
    queryParams.value.projectId = projectId.value;
    getList();
  });
}

function getList() {
  loading.value = true;
  queryProjectJcxmList(queryParams.value).then((res) => {
    mergeJcxmList.value = res.data;
    loading.value = false;
  });
}

function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

function resetQuery() {
  dateRange.value = [];
  proxy.resetForm("queryRef");
  handleQuery();
}

getId();

const heightParams = ref([{ tableName: "main", bottomHeight: 73 }]);
function getTableHeight() {
  proxy.adaptiveHeight(proxy, heightParams.value);
}
onMounted(() => {
  nextTick(function () {
    getTableHeight();
    window.addEventListener("resize", getTableHeight);
  });
});
onUpdated(() => {
  nextTick(function () {
    getTableHeight();
  });
});
onBeforeUnmount(() => {
  window.removeEventListener("resize", getTableHeight);
});

function transformation(row) {
  const a = proxy.getSupAndSub(row);
  return a;
}

projectListJclb({ projectId: projectId.value }).then((res) => {
  jclbList.value = res.data;
});
</script>

<style></style>
